Skip to content

Support whole-number float exponents in ReplacePowWithMulPass (#18851)#18851

Merged
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
khazaei:export-D100695654
Apr 16, 2026
Merged

Support whole-number float exponents in ReplacePowWithMulPass (#18851)#18851
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
khazaei:export-D100695654

Conversation

@khazaei
Copy link
Copy Markdown
Contributor

@khazaei khazaei commented Apr 13, 2026

Summary:

Extend ReplacePowWithMulPass to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched int typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:

  • Broaden the type check from isinstance(_, int) to isinstance(_, (int, float))
  • Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
  • Convert validated float exponents to int before proceeding
  • Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 13, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18851

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit 0c0afbe with merge base f35fbb5 (image):

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 13, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 13, 2026

@khazaei has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100695654.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot changed the title Support whole-number float exponents in ReplacePowWithMulPass Support whole-number float exponents in ReplacePowWithMulPass (#18851) Apr 14, 2026
@khazaei khazaei force-pushed the export-D100695654 branch from cc464b5 to 9b8346e Compare April 14, 2026 21:08
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 9b8346e to e6267b1 Compare April 14, 2026 21:10
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from e6267b1 to 6b1da40 Compare April 14, 2026 21:12
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch 2 times, most recently from db78fae to 55e1ed1 Compare April 15, 2026 06:20
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 55e1ed1 to 7ff743a Compare April 15, 2026 17:47
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 7ff743a to 7363e2e Compare April 15, 2026 17:51
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 7363e2e to 8ded622 Compare April 15, 2026 17:51
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 8ded622 to 264a8fe Compare April 15, 2026 17:55
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 15, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 264a8fe to ff96a62 Compare April 15, 2026 20:03
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from ff96a62 to 0c0afbe Compare April 15, 2026 20:06
@meta-codesync meta-codesync Bot merged commit a14c946 into pytorch:main Apr 16, 2026
163 of 165 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants